
#pragma once
#include <iostream>
#include <string>
#include <vector>


class CubStr
{
    public:
    static void cubstr(const std::string& str, const std::string& cub_sys, std::vector<std::string>& vec)
    {
        int start = 0;
        int next_start = -1;
        while ((start = str.find(cub_sys, start)) != str.npos)
        {
            start += cub_sys.length();
            next_start = str.find(cub_sys, start) + start; //找到下一个分割符起始下标
            std::cout << start  << " " << next_start<< std::endl;
            int last_prev = start;
            int prev = start;
            std::cout << "out :" << prev << std::endl;
            int tmp;
            while ((tmp = str.find(" ", prev)) != str.npos)
            {
                prev += tmp;
                if (prev > (next_start - start))
                break;

                std::cout << "pr:" << prev << " la:" << last_prev << std::endl;
                std::cout << "aa:" << str.substr(last_prev, prev - last_prev) << std::endl;
                vec.push_back(str.substr(last_prev, prev - last_prev));
                prev++;
                last_prev = prev;
                sleep(1);
            }

            if((start - cub_sys.size()) == last_prev)
            vec.push_back(str.substr(last_prev, next_start - last_prev));

        }
        
        for (auto& it : vec)
        {
            std::cout << "zz:" << it << std::endl;
        }
    }
};







